package com.liaoyifan.core.generator;

import com.liaoyifan.core.converter.handler.DateTimeHandler;
import java.time.LocalDate;
import java.util.Map;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ControllerModel {

    public static void build(Map<String, Object> dataModel) {
        ServiceModel.build(dataModel);
        dataModel.putIfAbsent(
                "controllerUrl", dataModel.get("table").toString().replaceAll("_", "/"));
        dataModel.putIfAbsent(
                "tagOrder",
                "-" + DateTimeHandler.fromLocalDate(LocalDate.now()).replaceAll("-", ""));
        dataModel.putIfAbsent(
                "controllerPackage",
                dataModel.get("modulePackage") + "." + Model.CONTROLLER.name().toLowerCase());
        dataModel.putIfAbsent(
                "controllerName", dataModel.get("entityName") + Model.CONTROLLER.getSuffix());
    }
}
